package com.whjz.dcfs.ssjk.dao;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import com.whjz.dcfs.ssjk.model.BdzData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.whjz.dcfs.ssjk.model.DcfsData;
import com.whjz.dcfs.ssjk.model.DcfsHsEmstime;
import com.whjz.dcfs.util.PageParam;

@Repository
public class DcfsHsEmstimeDAO implements IDcfsHsEmstimeDAO{

    @Autowired
    private SqlMapClient sqlMapClient;

    public void deleteDcfsHsEmstimeByCond(DcfsHsEmstime object) throws SQLException{
        sqlMapClient.delete("deleteDcfsHsEmstimeByCond", object);
    }

    public void deleteDcfsHsEmstimeListByCond(List<DcfsHsEmstime> list) throws SQLException{
        if (null != list) {
			sqlMapClient.startBatch();
            for (int i = 0; i < list.size(); i++) {
                deleteDcfsHsEmstimeByCond(list.get(i));
            }
			sqlMapClient.executeBatch();
        }
    }

    public List<DcfsHsEmstime> getDcfsHsEmstimeListByCond(DcfsHsEmstime object) throws SQLException{
        return sqlMapClient.queryForList("getDcfsHsEmstimeByCond", object);
    }
    
    public List<DcfsHsEmstime> getDcfsHsEmstimeListByCondNew(String xzqh) throws SQLException{
    	if("test".equals(xzqh)){
    		return sqlMapClient.queryForList("getDcfsHsEmstimeAll");
    	}else{
    		return sqlMapClient.queryForList("getDcfsHsEmstimeByCondNew", xzqh);
    	}
    }
    public PageParam queryPageInfo(DcfsHsEmstime object,PageParam pageParam) throws SQLException{
		pageParam.setPageIndex(pageParam.getPageIndex());
		object.setPageIndex(pageParam.getPageIndex());
		object.setPageLast(pageParam.getPageLast());
		int totalCount = ((Integer)sqlMapClient.queryForObject("queryDcfsHsEmstimeCount",object)).intValue();
		List<DcfsHsEmstime> list = sqlMapClient.queryForList("queryDcfsHsEmstimePage",object);
		pageParam.setResult(list);
		pageParam.setTotalCount(totalCount);
		pageParam.setTotalPage(pageParam.getTotalPage());
		return pageParam;
    }

	public List<DcfsData> getsssjByCond(Map map) throws SQLException {
		return sqlMapClient.queryForList("getsssjByCond", map);
	}

	public List<DcfsData> getStatisticsDay(Map map) throws SQLException {
		return sqlMapClient.queryForList("getStaDay", map);
	}

	public List<BdzData> getMaxData(Map map) throws SQLException {
		return sqlMapClient.queryForList("getMaxData", map);
	}

	public List<BdzData> getToday(Map map) throws SQLException {
		return sqlMapClient.queryForList("getBdzToday", map);
	}

	public List<DcfsData> getStaWeek(Map map) throws SQLException {
		return sqlMapClient.queryForList("getStaWeek", map);
	}
	public List<DcfsData> getStaMonth(Map map) throws SQLException {
		return sqlMapClient.queryForList("getStaMonth", map);
	}

	@Override
	public List<BdzData> getBdzWeek(Map map) throws SQLException {
		return sqlMapClient.queryForList("getBdzWeek", map);
	}

	@Override
	public List<BdzData> getBdzMonth(Map map) throws SQLException {
		return sqlMapClient.queryForList("getBdzMonth", map);
	}

	@Override
	public List<BdzData> getMinuteReportData(Map map) throws SQLException {
		return sqlMapClient.queryForList("getMinuteReportData", map);
	}

	@Override
	public List<BdzData> getDayReportData(Map map) throws SQLException {
		return sqlMapClient.queryForList("getDayReportData", map);
	}

	@Override
	public List<BdzData> getHourReportData(Map map) throws SQLException {
		return sqlMapClient.queryForList("getHourReportData", map);
	}

}